#e
#Title[uffBX^Xv]
#Text[\Z̃XyJ[h]
#BackGround[Default]
#Player[FREE]
#ScriptVersion[2]

script_enemy_main
{
        let count=0;
        let name    = "uffBX^Xv";
        let csd     = GetCurrentScriptDirectory;
        let imgBoss =csd~"img\dot_sakuya.png";
	let imgEnemy=csd~"img\familiar.png";
        let angle = 0;
	let AnimationA=0;
	let AnimationB=0;
	let AnimationC=0;

    @Initialize {
        CutIn(YOUMU, name, 0, 0, 0, 0, 0);

        SetLife(4000);
        SetTimer(70);
        SetScore(1000000);
        SetDamageRate(0,0);

        SetInvincibility(0);
        SetMovePosition02(GetCenterX(),120,60);
	LoadGraphic(imgEnemy);
	LoadGraphic(imgBoss);
        TAnime1;
    }

        @MainLoop
        {
	if(count==100){
	let angleFam = [0,60,120,180,240,300];
	ascent(i in 0..6) {
	CreateEnemyFromScript("EnemyA",GetX,GetY,0,angleFam[i],1);
	CreateEnemyFromScript("EnemyB",GetX,GetY,0,angleFam[i],1);
        	}
        }
	if(count==150)
	{
		Concentration02(60);
        }
	if(count>=200&&count%50==0){
        SetDamageRate(100,100);
        SetShotDirectionType(PLAYER);
			let i=0;
			while(i<5)
			{
        		SetShotDirectionType(PLAYER);
			let shotA=0;
			CreateShotA(shotA,GetX(),GetY(),10);
			SetShotDataA(shotA,0,0.5,i*20-40,0,0.01,1.5,BLUE32);
			FireShot(shotA);
			CreateShotA(shotA,GetX(),GetY(),10);
			SetShotDataA(shotA,0,1,i*20-40,0,0.01,2,RED32);
			FireShot(shotA);
			i=i+1;
			}
		}
	if(count>=400&&count%200==0){
		SetMovePosition02(rand(GetCenterX()-75,GetCenterX()+75),rand(80,180),50);
		}
        SetCollisionA(GetX(),GetY(),18);
        SetCollisionB(GetX(),GetY(),18);
        count++;
        yield;

}

        @DrawLoop {
		SetRenderState(ALPHA);
		SetTexture(imgBoss);
		SetGraphicScale(1,1);
		SetAlpha(255);
		SetColor(255,255,255);
		SetGraphicAngle(0,0,0);
		if(int(GetSpeedX())==0)
		{SetGraphicRect(128*AnimationC,128*AnimationB,127+128*AnimationC,127+128*AnimationB);}
		else if(GetSpeedX()>0){SetGraphicRect(256,256+128*AnimationA,383,383+128*AnimationA);}
		else if(GetSpeedX()<0){SetGraphicRect(256,128*AnimationA,383,127+128*AnimationA);}
		DrawGraphic(GetX(),GetY());
	}
        
        @Finalize
        {
                DeleteGraphic(imgBoss);
        }

    	task TAnime1{
			AnimationB=0;
			AnimationC=3;
        		loop(16){yield;}
			AnimationB=1;
        		loop(56){yield;}
			AnimationB=0;
        		loop(8){yield;}
		loop{
			AnimationB=0;
			AnimationC=0;
        		loop(10){yield;}
			AnimationB=1;
        		loop(10){yield;}
			AnimationB=2;
        		loop(10){yield;}
			}
		}

    	task TAnime2{
			AnimationA=0;
        		loop(10){yield;}
			AnimationA=1;
        		loop(30){yield;}
			AnimationA=0;
        		loop(10){yield;}
		}
}

script_enemy EnemyA
{
	let count=0;
	let imgAngle=0;
        let cx=GetCenterX();
        let cy=GetCenterY();
	let Zoom=0;
	let angle=GetAngle;
	let angleB=GetAngle;
	let csd     = GetCurrentScriptDirectory;
	let imgEnemy=csd~"img\familiar.png";
	@Initialize
	{
		SetLife(30);
		SetX(GetEnemyX);
		SetY(GetEnemyY);
		SetMovePosition02(GetEnemyX+cos(angle)*100,GetEnemyY+sin(angle)*100,50);
	}
	
	@MainLoop
	{
		imgAngle+=4;
		if(imgAngle>360){imgAngle=0;}

		Zoom+=0.02;
		if(Zoom>1){Zoom=1;}

        	if(count>=50&&count%5==0)
        	{
		SetMovePosition02(GetEnemyX+cos(angle)*atan2(GetPlayerY-GetEnemyY(),GetPlayerX-GetEnemyX()),GetEnemyY+sin(angle)*atan2(GetPlayerY-GetEnemyY(),GetPlayerX-GetEnemyX()),10);
        	angle=angle-5;
        	}

        	if(count>=50&&count%5==0)
        	{
			let shotA=0;
			CreateShotA(shotA,GetX,GetY,5);
			SetShotDataA(shotA,0,1,angleB,0,0.01,2,RED31);
			FireShot(shotA);
			angleB=angleB-20;
        	}
		count++;
	}
	
	@Finalize
	{
	}
	
	@DrawLoop
	{
		SetGraphicRect(0,0,47,47);
		SetTexture(imgEnemy);
		SetGraphicScale(Zoom,Zoom);
		SetColor(255,155,155);
		SetRenderState(ALPHA);
		SetGraphicAngle(0,0,imgAngle);
		DrawGraphic(GetX(),GetY());
		SetRenderState(ALPHA);
		SetGraphicAngle(0,0,-imgAngle);
		DrawGraphic(GetX(),GetY());
	}
}

script_enemy EnemyB
{
	let count=0;
	let imgAngle=0;
        let cx=GetCenterX();
        let cy=GetCenterY();
	let Zoom=0;
	let angle=GetAngle;
	let angleB=GetAngle;
	let csd     = GetCurrentScriptDirectory;
	let imgEnemy=csd~"img\familiar.png";
	@Initialize
	{
		SetLife(30);
		SetX(GetEnemyX);
		SetY(GetEnemyY);
		SetMovePosition02(GetEnemyX+cos(angle)*200,GetEnemyY+sin(angle)*200,50);
	}
	
	@MainLoop
	{
		imgAngle+=4;
		if(imgAngle>360){imgAngle=0;}

		Zoom+=0.02;
		if(Zoom>1){Zoom=1;}

        	if(count>=50&&count%5==0)
        	{
		SetMovePosition02(GetEnemyX+cos(angle)*atan2(GetPlayerY-GetEnemyY(),GetPlayerX-GetEnemyX())*2,GetEnemyY+sin(angle)*atan2(GetPlayerY-GetEnemyY(),GetPlayerX-GetEnemyX())*2,10);
        	angle=angle+5;
        	}

        	if(count>=50&&count%5==0)
        	{
			let shotA=0;
			CreateShotA(shotA,GetX,GetY,5);
			SetShotDataA(shotA,0,2,angleB,0,-0.01,1,BLUE31);
			FireShot(shotA);
			angleB=angleB+20;
        	}
		count++;
	}
	
	@Finalize
	{
	}
	
	@DrawLoop
	{
		SetGraphicRect(0,0,47,47);
		SetTexture(imgEnemy);
		SetGraphicScale(Zoom,Zoom);
		SetColor(155,155,255);
		SetRenderState(ALPHA);
		SetGraphicAngle(0,0,imgAngle);
		DrawGraphic(GetX(),GetY());
		SetRenderState(ALPHA);
		SetGraphicAngle(0,0,-imgAngle);
		DrawGraphic(GetX(),GetY());
	}
}